import { defineConfig } from 'vite'
// @ts-ignore
import vue from '@vitejs/plugin-vue'
// @ts-ignore
import path from 'path'

// https://vite.dev/config/
// @ts-ignore
export default defineConfig({
  plugins: [vue()],
  server: {
    cors: true, 	// 默认启用并允许任何源
    open: false, 	// 在服务器启动时自动在浏览器中打开应用程序
    port: 3000,
    proxy: {
      '/api': {
        target: 'http://localhost:8080/boke',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/img': {
        target: 'http://localhost:8080/boke/myboke',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/img/, '')
      },
    },
  },
  resolve: {
    alias: {
      // @ts-ignore
      '@' :path.resolve(__dirname, 'src')
    }
  }
})
